<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('projects', function (Blueprint $table) {
            $table->id();
            $table->string('title');
            $table->text('description')->nullable();
            $table->foreignId('user_id')->constrained()->cascadeOnDelete();
            $table->text('package_json')->nullable();
            $table->string('download_link')->nullable();
            $table->string('project_type')->nullable();
            $table->string('remark')->nullable();
            $table->timestamps();
        });

        DB::table('projects')->insert([
            [
            'title' => 'Project 1',
            'user_id' => 1,
            'download_link' => 'https://github.com',
            'project_type' => 'vue',
            'remark' => 'This is a project',
            'created_at' => now(),
            'updated_at' => now(),
            ],
            [
                'title' => 'Project 2',
                'user_id' => 2,
                'download_link' => 'https://github.com',
                'project_type' => 'vue',
                'remark' => 'This is a project',
                'created_at' => now(),
                'updated_at' => now(),
            ]
        ]);
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('projects');
    }
};
